@extends('admin.inc.base')
@section('content')
    <div style="padding:5px 0 10px 0;">当前推荐位：<b style="color:red">{{$recommend->title}}</b>&nbsp;推荐位标志：<b style="color:red">{{$recommend->position}}</b></div>
    <table class="table">
        <tr>
            <th>序号</th>
            <th>标题</th>
            <th>操作</th>
        </tr>
        @foreach($data as $key => $post)
            <tr>
                <td>{{ $key }}</td>
                <td>{{ $post -> title }}</td>
                <td>
                    <a href="javascript:;" data-postid="{{$post->id}}" class="cancelRec">取消推荐</a>
                </td>
            </tr>
        @endforeach
    </table>

    <script type="text/javascript">
        $(function(){
            $(".cancelRec").click(function(){
                var postId = $(this).data('postid');
                var that = this;
                $.get('/administrator/recommend/{{$recommend->id}}/cancelAppend/'+postId,function(data){
                    alert(data.message);
                    console.log(data);
                    if(data.state=='ok'){
                        $(that).parent().parent().remove();
                    }
                },'JSON');
            });

        })
    </script>

@endsection